import java.util.Scanner;

public class demo1 {
    //OutOfMemoryError
    public static void main1(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        if (num <= 2) {
            System.out.println(-1);
        } else {
            long[][] dp = new long[num][num * 2 - 1];
            dp[0][0] = 1;
            for (int i = 1; i < num; i++) {
                dp[i][0] = 1;
                dp[i][2 * i] = 1;
                for (int j = 1; j < 2 * i; j++) {
                    if (j == 1) {
                        dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1];
                    } else {
                        dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1] + dp[i - 1][j - 2];
                    }
                }
            }
            for (int i = 0; i <= num; i++) {
                if (dp[num - 1][i] % 2 == 0) {
                    System.out.println(i+1);
                    return;
                }
            }
            System.out.println(-1);
        }
    }

    public static void main2(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        if (num <= 2) {
            System.out.println(-1);
        } else {
            long[] dp = new long[num*2-1];
            dp[0] = 1; dp[1] = 1; dp[2]=1;
            for (int i = 3; i <= num; i++) {
                for (int j = 1; j <= i; j++) {
                    if(j == 1){
                        dp[j] = dp[j] + dp[j-1];
                    }else{
                        dp[j] = dp[j] + dp[j-1] + dp[j-2];
                    }
                }
            }
            for (int i = 0; i <= num; i++) {
                if(dp[i] % 2== 0){
                    System.out.println(i+1);
                    return;
                }
            }
            System.out.println(-1);
        }
    }
    public static void main3(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        if (num <= 2) {
            System.out.println(-1);
        } else {
            long[] dp = new long[num * 2 - 1];
            dp[0] = 1;
            dp[1] = 1;
            dp[2] = 1;
            for (int i = 3; i <= num; i++) {
                for (int j = 1; j < 4; j++) {
                    if (j == 1) {
                        dp[j] = dp[j] + dp[j - 1];
                    } else {
                        dp[j] = dp[j] + dp[j - 1] + dp[j - 2];
                    }
                }
            }
            for (int i = 0; i < 4; i++) {
                if (dp[i] % 2 == 0) {
                    System.out.println(i + 1);
                    return;
                }
            }
            System.out.println(-1);
        }
    }
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num = scan.nextInt();
        if (num <= 2) {
            System.out.println(-1);
        } else {
            if ((num - 2) % 4 == 0) {
                System.out.println(4);
            } else {
                if ((num - 2) % 4 % 2 == 1) {
                    System.out.println(2);
                } else {
                    System.out.println(3);
                }
            }
        }
    }
}
